<%@ page contentType="text/html;charset=UTF-8" %>
<script>
    function onBridgeReady(){
       var param = {
            "appId":"<%=request.getParameter("appId")%>",
            "timeStamp":"<%=request.getParameter("timeStamp")%>",
            "nonceStr":"<%=request.getParameter("nonceStr")%>",
            "package":"<%=request.getParameter("package")%>",
            "signType":"MD5",
            "paySign":"<%=request.getParameter("paySign")%>"
        };

        WeixinJSBridge.invoke(
            'getBrandWCPayRequest', param,
            function(res){
                if(res.err_code == -1){
                    alert(JSON.stringify(res.err_desc));
                    return;
                }
                WeixinJSBridge.call('closeWindow');
            }
        );
    }
    if (typeof WeixinJSBridge == "undefined"){
        if( document.addEventListener ){
            document.addEventListener('WeixinJSBridgeReady', onBridgeReady, false);
        }else if (document.attachEvent){
            document.attachEvent('WeixinJSBridgeReady', onBridgeReady);
            document.attachEvent('onWeixinJSBridgeReady', onBridgeReady);
        }
    }else{
        onBridgeReady();
    }
</script>